package net.starwifi.duobao.web;

import net.starwifi.duobao.dto.JXDTO;
import net.starwifi.duobao.mvc.*;
import net.starwifi.duobao.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * Created by Administrator on 2015/9/24.
 */
@Controller("apiFactoryController")
@RequestMapping("/jx")
public class JXController extends BaseController {

    @Autowired
    MemberService memberService;

    /**
     * 列表
     */
    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Object list(int pageNum) {
        PageView pageView=new PageView(pageNum,10);
        pageView.addFilter(Filter.eq("isMarketable", Boolean.TRUE));
        pageView.addFilter(Filter.eq("memberType", 1)); //商家用户
        pageView.addOrder(Order.desc("id"));
        final Page page=memberService.getScrollData(pageView);
        return Message.createMessage(Message.success("success"), new HashMap<String, Object>() {{
            put("list", JXDTO.getList(page.getContent()));
        }});
    }


}
